<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文件上传</title>
    <link rel="stylesheet" href="ext-4.2.1.883/resources/css/ext-all.css">
    <script type="text/javascript" src="ext-4.2.1.883/ext-all.js"></script>
    <script type="text/javascript" src="ext-4.2.1.883/locale/ext-lang-zh_CN.js"></script>
</head>
<body>
<script type="text/javascript">

    Ext.onReady(function () {
        Ext.create('Ext.form.Panel', {
            title: '文件上传',
            width: 400,
            bodyPadding: 10,
            frame: true,
            renderTo: Ext.getBody(),
            items: [{
                xtype: 'filefield',
                name: 'excel',
                fieldLabel: '文件:',
                labelWidth: 50,
                msgTarget: 'side',
                allowBlank: false,
                anchor: '100%',
                buttonText: '选择文件'
            }],
            buttons: [{
                text: '上传',
                handler: function() {
                    var form = this.up('form').getForm();
                    if(form.isValid()){
                        form.submit({
                            url: 'xxxx',
                            waitMsg: '正在上传',
                            success: function(fp, o) {
                                Ext.Msg.alert('Success', 'Your photo "' + o.result.file + '" has been uploaded.');
                            },
                            failure: function (fp, o) {
                                Ext.Msg.alert("上传失败","文件上传失败")
                            }
                        });
                    }
                }
            }]
        });
    })

</script>
</body>
</html>